package com.shawn.server.controller;

import com.shawn.model.vo.HXUserVo;
import com.shawn.server.interceptor.ThreadContext;
import com.shawn.server.service.HXService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/huanxin")
public class HXController {

    @Autowired
    private HXService hxService;

    /**
     * 获取环信账户
     *
     * @return {@link ResponseEntity}
     */
    @GetMapping("/user")
    public ResponseEntity getHXAccount(){
        Long userId = ThreadContext.getUserId();

        HXUserVo hxAccount = hxService.getHXAccount(userId);
        log.info("获取到ID:{}==>环信账户:{}",userId,hxAccount.toString());
        return ResponseEntity.ok(hxAccount);
    }


}
